package shiyanbaogao;

    import java.util.Scanner;
    public class Test1 {

    public static class SalaryCalculator {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            boolean running = true;

            while (running) {
                // 1. 显示欢迎信息和菜单
                System.out.println("\n===== 职工工资管理系统 ======");
                System.out.println("1. 录入职工信息及工资");
                System.out.println("2. 退出系统");
                System.out.print("请选择菜单编号：");

                // 2. 接收并验证菜单输入
                int choice;
                while (!scanner.hasNextInt()) {
                    System.out.print("输入无效，请重新输入菜单编号：");
                    scanner.next(); // 清除无效输入
                }
                choice = scanner.nextInt();
                scanner.nextLine(); // 消耗换行符

                switch (choice) {
                    case 1:
                        // 3. 录入职工个人信息
                        System.out.print("请输入职工姓名：");
                        String name = scanner.nextLine();

                        System.out.print("请输入职工工号：");
                        String id = scanner.nextLine();

                        System.out.print("请输入职工部门：");
                        String department = scanner.nextLine();

                        // 4. 录入工资信息
                        System.out.print("请输入基本工资：");
                        double basicSalary = scanner.nextDouble();

                        System.out.print("请输入奖金：");
                        double bonus = scanner.nextDouble();

                        System.out.print("请输入津贴：");
                        double allowance = scanner.nextDouble();

                        // 5. 计算工资（示例规则：总工资=基本工资+奖金+津贴）
                        double totalSalary = basicSalary + bonus + allowance;
                        System.out.println("\n===== 工资计算结果 ======");
                        System.out.println("职工姓名：" + name);
                        System.out.println("工号：" + id);
                        System.out.println("部门：" + department);
                        System.out.println("总工资：¥" + String.format("%.2f", totalSalary));
                        break;

                    case 2:
                        System.out.println("系统已退出，再见！");
                        running = false;
                        break;

                    default:
                        System.out.println("无效的菜单编号，请重新选择！");
                }
            }
            scanner.close();
        }
    }

}
